<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%
	String lng = request.getParameter("lng");
	String lat = request.getParameter("lat");

%>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
	<title>路线规划</title>
	<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
	<style type="text/css">
		#panel {
			position: fixed;
			background-color: white;
			max-height: 50%;
			overflow-y: auto;
			top: 10px;
			right: 10px;
			width: 200px;
		}
	</style>
	<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.0&key=e8496e8ac4b0f01100b98da5bde96597&plugin=AMap.Driving"></script>
	<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<div id="panel"></div>
<script type="text/javascript">
	//所在地位置
	var locLng = "";
	var locLat = "";

	//目的地的经纬度
	var lng = "<%=lng%>";
	var lat = "<%=lat%>";



	//基本地图加载
	var map = new AMap.Map("container", {
		resizeEnable: true,
		center: [118.027308,24.470477],//地图中心点
		zoom: 13 //地图显示的缩放级别
	});


	map.plugin('AMap.Geolocation', function() {
		geolocation = new AMap.Geolocation({
			enableHighAccuracy: true,//是否使用高精度定位，默认:true
			timeout: 10000,          //超过10秒后停止定位，默认：无穷大
			buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
			zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
			buttonPosition:'LB'
		});
		map.addControl(geolocation);
		geolocation.getCurrentPosition();
		AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
//			AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
	});


	//解析定位结果
	function onComplete(data) {
		var str=['定位成功'];
		str.push('经度：' + data.position.getLng());
		str.push('纬度：' + data.position.getLat());
		if(data.accuracy){
			str.push('精度：' + data.accuracy + ' 米');
		}//如为IP精确定位结果则没有精度信息
		str.push('是否经过偏移：' + (data.isConverted ? '是' : '否'));
		locLng = data.position.getLng();
		locLat = data.position.getLat();

		//构造路线导航类
		var driving = new AMap.Driving({
			map: map,
			panel: "panel"
		});
		// 根据起终点经纬度规划驾车导航路线
		driving.search(new AMap.LngLat(locLng,locLat), new AMap.LngLat(lng,lat));
	}


</script>
</body>
</html>